package main

import (
	"haili/actions"

	"github.com/lunny/tango"
)

func Router(t *tango.Tango) {
	t.Get("/ico/:name", tango.Dir("./static/avatar"))

	t.Any("/users/:name", new(actions.UserAction))
	//注册用户
	t.Post("/register", func(ctx *tango.Context) {
		ret := actions.RegisterUser(ctx)
		ctx.ServeJson(ret)

	})
	//用户登录
	t.Post("/login", func(ctx *tango.Context) {
		ret := actions.Login(ctx)
		ctx.ServeJson(ret)
	})

	t.Post("/smscode", new(actions.SMSVerCodeAction))
	//检查手机号是否可注册
	t.Post("/checkPhone", func(ctx *tango.Context) {
		ret := actions.CheckPhone(ctx)
		ctx.ServeJson(ret)
	})
	//检查验证码
	t.Post("/checksmscode", func(ctx *tango.Context) {
		ret := actions.VerificationSMSCode(ctx)
		ctx.ServeJson(ret)
	})
	//修改用户
	t.Post("/update", func(ctx *tango.Context) {
		ret := actions.UpdateUser(ctx)
		ctx.ServeJson(ret)
	})

	//验证码
	t.Any("/captcha", new(actions.CaptchaAction))

	//图片上传
	// t.Any("/upload", func(ctx *tango.Context) {
	// 	common.UploadHandler(ctx.ResponseWriter, ctx.Req())
	// })

}
